package gcp.gui;

import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

/**
 * PainelNota<br>
 * Painel para exibicao das notas atribuidas ao itens colecionaveis.
 * @author Hildegard Furtado.
 */
public class PainelNota extends JPanel {

    private static final long serialVersionUID = 1L;

    private int nota;

    private Image nota0;
    private Image nota1;
    private Image nota2;
    private Image nota3;
    private Image nota4;

    /**
     * Construtor padrao.
     */
    public PainelNota() {
        super();
        nota = 0;
        nota0 = new ImageIcon("1.png").getImage();
        nota1 = new ImageIcon("2.png").getImage();
        nota2 = new ImageIcon("3.png").getImage();
        nota3 = new ImageIcon("4.png").getImage();
        nota4 = new ImageIcon("5.png").getImage();
    }

    /**
     * Retorna a nota.
     * @return Nota.
     */
    public int getNota() {
        return nota;
    }

    /**
     * Define a nota.
     * @param nota Nota do item.
     */
    public void setNota(int nota) {
        this.nota = nota;
        repaint();
    }
    
    /**
     * Incrementa a nota.
     */
    public void incrementar() {
        if (nota < 4) {
            nota++;
            repaint();
        }
    }
    
    /**
     * Decrementa a nota.
     */
    public void decrementar() {
        if (nota > 0) {
            nota--;
            repaint();
        }
    }

    /*
     * (non-Javadoc)
     * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
     */
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        switch (nota) {
        case 0:
            g.drawImage(nota0, 0, 0, null);
            break;
        case 1:
            g.drawImage(nota1, 0, 0, null);
            break;
        case 2:
            g.drawImage(nota2, 0, 0, null);
            break;
        case 3:
            g.drawImage(nota3, 0, 0, null);
            break;
        case 4:
            g.drawImage(nota4, 0, 0, null);
            break;
        }
    }
}